﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mortgage.DAL.Entity;
using Mortgage.DAL;
namespace Mortgage.Srv
{
    public interface IConfigTypeSrv
    {
        List<tzConfigType> GetAll();
        tzConfigType GetByCode(string code);
        tzConfigType GetById(int id);
    }
    class ConfigTypeSrv: IConfigTypeSrv
    {
        private MortgageDataContext dataContext;

        public ConfigTypeSrv()
        {
            dataContext = new MortgageDataContext();

        }

        public List<tzConfigType> GetAll()
        {
            return dataContext.tzConfigTypes.OrderBy(t => t.SortOrder).ToList();
        }

        public tzConfigType GetById(int id)
        {
            return dataContext.tzConfigTypes.Where(t => t.ID == id).FirstOrDefault();
        }

        public tzConfigType GetByCode(string code)
        {
            return dataContext.tzConfigTypes.Where(t => t.Code == code).FirstOrDefault();
        }
    }

}
